package com.asc.suites.test {
import com.asc.Comparable;
import com.asc.ObjectTestCase;
import com.asc.test.DefaultComparable;

import org.flexunit.assertThat;
import org.flexunit.asserts.assertEquals;
import org.hamcrest.object.equalTo;

public class DefaultComparableTest extends DefaultIdentifiableTest {
  public function DefaultComparableTest() {
    super();
  }


  override public function get referenceItem():* {
    return new DefaultComparable(referenceItemCount);
  }

  override public function get testItem():* {
    return new DefaultComparable(testItemCount);
  }


  override protected function verify():void {
    super.verify();
    const ri:Comparable = referenceItem as Comparable
    const ti:Comparable = testItem as Comparable
    verifyRandom();
  }

  private function verifyRandom() : void {
    for(var i:int = 0; i < 20; ++i) {
      const num1:int = (int) (Math.random() * 20) + 10;
      const num2:int = (int) (Math.random() * 30) + 20;

      const r1:Comparable = new DefaultComparable(num1);
      const r2:Comparable = new DefaultComparable(num2);
      assertThat(
        r1.compareTo(r2),
        equalTo(-r2.compareTo(r1))
      );
    }

  }
}
}